package com.subfg.common.constant;

import com.subfg.common.entity.excpetion.BusinessExceptionModel;
import org.jetbrains.annotations.NotNull;

public enum PayMethodEnum {
    PAY_ALI(1, "Ali Pay"),
    PAY_WECHAT(2, "Wechat Pay"),
    PAY_STRIPE(3, "Stripe"),
    PAY_BALANCE(4, "Balance"),
    PAY_APPLE(7, "Apple Pay")
    ;
    private Integer value;
    private String payType;

    PayMethodEnum(Integer value, String payType) {
        this.value = value;
        this.payType = payType;
    }
    public Integer getValue() {
        return value;
    }
    public String getPayType() {
        return payType;
    }

    /**
     * 系统支持的支付方式
     * @param payType
     * @return
     */
    @NotNull
    public static PayMethodEnum getSysPatMethod(String payType) throws BusinessExceptionModel {
        Integer channel = Integer.valueOf(payType);
        if (channel != null) {
            for (PayMethodEnum payMethod : PayMethodEnum.values()) {
                if (channel.equals(payMethod.getValue())) {
                    return payMethod;
                }
            }
        }
        throw new BusinessExceptionModel();
    }
}
